package edu.scut.course_management.dto;

import edu.scut.course_management.po.Resource;
import edu.scut.course_management.po.Section;

import java.util.List;

/**
 * 有关课程资源请求的数据传输对象
 * 用来封装有关课程资源的请求的请求参数
 * @author shawshank
 */
public class RequestForResourceDTO {

	private Integer nodeId;
	private List<Section> sections;
	private Resource resourceNode;

	public Integer getNodeId() {
		return nodeId;
	}

	public void setNodeId(Integer nodeId) {
		this.nodeId = nodeId;
	}

	public List<Section> getSections() {
		return sections;
	}

	public void setSections(List<Section> sections) {
		this.sections = sections;
	}

	public Resource getResourceNode() {
		return resourceNode;
	}

	public void setResourceNode(Resource resourceNode) {
		this.resourceNode = resourceNode;
	}

	public boolean checkParamValidity(boolean haveResource) {
		if (sections == null || sections.isEmpty() || nodeId == null) {
			return false;
		}
		if (haveResource == true && resourceNode == null) {
			return false;
		}
		for (Section section: sections) {
			if (section.getCourseId() == null || section.getPeriodId() == null || section.getBuildingId() == null ||
				section.getRoomNumber() == null || section.getYear() == null || section.getTerm() == null) {
				return false;
			}
		}
		return true;
	}

}
